﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tencent.OA.App;
using System.Web;

namespace Tencent.OA.ACM.App
{
    /// <summary>
    /// 文档管理系统权限验证
    /// </summary>
    public class BancheSiteMapNodeVisibilityProvider : ISiteMapNodeVisibilityProvider
    {
        #region ISiteMapNodeVisibilityProvider 成员

        public bool IsVisible(SiteMapNode node, HttpContext context, IDictionary<string, object> sourceMetadata)
        {           
            MvcSiteMapNode mapNode = node as MvcSiteMapNode;
            if (mapNode == null)
                return false;

            // 如果设置了忽略权限，则直接跳过
            if (mapNode.IgnoreRole)
                return true;

            // TOF登录后，首页不需另做权限验证
            //
            if (mapNode.IsRootNode)
                return true;

            if (!string.IsNullOrEmpty(mapNode.OperationCode))
            {
                return Authentication.CheckRight(mapNode.OperationCode);
            }

            // 如果没有设置OperationCode,则默认有权限访问
            return true;
        }

        #endregion
 
    }
}
